import pandas as pd
from pyecharts.charts import  Map
from pyecharts import  options as opts

data=pd.read_excel("塑料废物污染(1).xlsx")
country=list(data["Country"])
pollution=list(data["percent"])
list=[list(z)for z in zip (country,pollution)]

print(list)

c=(Map(init_opts=opts.InitOpts(width="2000px",height="1000px",renderer="svg")))

c.set_global_opts(
    title_opts=opts.TitleOpts(title="各个国家未处理塑料废物占比"),
    visualmap_opts=opts.VisualMapOpts(type_="color",pos_left="left",pos_top="middle",orient="vertical",is_piecewise=True,min_=0,max_=1,out_of_range=[{"color":'black'}],
                                      pieces=[{"gt":1.0,"color":'red'},
                                              {"min":0.9,"max":1.0,"label":"0.9-1.0"},
                                              {"min":0.8,"max":0.9,"label":"0.8-0.9"},
                                              {"min":0.7,"max":0.8,"label":"0.7-0.8"},
                                              {"min":0.6,"max":0.7,"label":"0.6-0.7"},
                                              {"min":0.5,"max":0.6,"label":"0.5-0.6"},
                                              {"min":0.4,"max":0.5,"label":"0.4-0.5"},
                                              {"min":0.3,"max":0.4,"label":"0.3-0.4"},
                                              {"min":0.2,"max":0.3,"label":"0.2-0.3"},
                                              {"min":0.1,"max":0.2,"label":"0.1-0.2"},
                                              {"min":0,"max":0.1,"label":"0-0.1"}]),
    toolbox_opts=opts.ToolboxOpts(is_show=True)
)
c.add("缺乏管理塑料废物占总塑料废物比值",list,maptype="world")

c.render("各国塑料污染状况.html")